/*
 * date: 2009-11-20 
 * author: Maciej Smolenski <jezdnia@gmail.com>
 */
#ifndef _COMMON_HPP_
#define _COMMON_HPP_

#include <stdlib.h>
#include <set>
#include <iostream>
#include <iterator>
#include "rpc_monitor_data.hpp"
#include "rpc_config_data.hpp"

namespace rc=rpc_config;
namespace rm=rpc_monitor;

#define PR(code) std::cout << code << std::endl;

#define PR_EXIT(code, value) do{PR(code) exit(value);}while(0);

#define PRINT_INFO(info) fprintf(stderr, "%s:%d %s\n", __FILE__, __LINE__, info); 

#define RETURN_INFO(info, val) do{PRINT_INFO(info) return val; }while(0);

template<typename T>
int print_set(std::set<T> &s, const char *sep);

int fill(std::set<rc::rpc_host_entry_string> &set, int num);
int fill(std::set<rm::rpc_service_string> &set, int num);

template<typename T>
int print_set(std::set<T> &s, const char *sep)
{
	std::copy(s.begin(), s.end(), std::ostream_iterator<T>(std::cout, sep));
	std::cout << std::endl;

	return 0;
}

#endif
